﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections;
using System.IO;
using System.Drawing;
using System.Text;

public partial class outRecordList1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["name"] == null)
        {
            Response.Redirect("~/error.aspx?");
        }
        else
        {
            if (!IsPostBack)
            {
                this.bind();
            }
        }
    }
    public SqlConnection GetConnection()
    {
        string myStr = ConfigurationManager.AppSettings["ConnectionString"].ToString();
        SqlConnection myConn = new SqlConnection(myStr);
        return myConn;
    }

    protected void bind()
    {
        SqlConnection myConn = GetConnection();
        myConn.Open();
        //string sqlStr = "select RID as 编号 , RGID as 货品编号,GTYPEName as 类别,GCHName as 名称,GXinhao as 型号,GBrand as 品牌,  RWID as 仓库编号,RQuantity as 数量,RHandler as 出货人,RDate as 日期, RifAOG as 出货确认,RComfirmer as 确认人,RComfirmedDate as 确认日期,  bianhao as 项目编号,PName as 项目名 from Projects,RecordsOUT, Goods where RecordsOUT.RGID=Goods.GID and RecordsOUT.RPID=Projects.PID and RecordsOUT.RDID='"+Session["ODID"].ToString()+"' order by RID desc";
        string sqlStr = "select RID as 编号 , RGID as 货品编号,GTYPEName as 类别,GCHName as 名称,GXinhao as 型号,GBrand as 品牌,  RWID as 仓库编号,RQuantity as 数量,PQuantity as 项目库存,RHandler as 出货人,RDate as 日期, RifAOG as 出货确认,RComfirmer as 确认人,RComfirmedDate as 确认日期,bianhao as 项目编号,Projects.PName as 项目名  from RecordsOUT, Goods,Projects,ProjectsQuantity where RecordsOUT.RGID=Goods.GID and RecordsOUT.RGID=ProjectsQuantity.PGID and RecordsOUT.RPID=Projects.PID and  RecordsOUT.RPID=ProjectsQuantity.PID and  RecordsOUT.RDID='" + Session["ODID"].ToString() + "' order by RID desc";

        SqlDataAdapter myDa = new SqlDataAdapter(sqlStr, myConn);
        DataSet myDs = new DataSet();
        myDa.Fill(myDs);
        GridView1.DataSource = myDs;
        GridView1.DataKeyNames = new string[] { "编号" };
        GridView1.DataBind();
        myDa.Dispose();
        myDs.Dispose();
        myConn.Close();
    }
    protected void dayin_Click(object sender, EventArgs e)
    {

        // Response.Redirect("~/dayin.aspx?");
        Response.Write("<script language='javascript'>window.open('dayin.aspx');</script>");
    }
}